import {getFileVersion,getFileVersionContent} from '../../utils/nc/version'
import {description, path, request, summary, tagsAll} from "koa-swagger-decorator-fork";
import responseMapper from "../../utils/responseMapper";

@tagsAll(['VersionFile'])
export default class VersionFileRouter {
    @request('GET', '/files/versions/{id}')
    @summary('get file versions by file id')
    @path({ id: { type: 'string', required: true } })
    @description('查询文件历史版本')
    static async getFileVersion(ctx) {
        let files = await getFileVersion(ctx.client,ctx.user,ctx.params.id)
        let result = responseMapper.wrapResponse(ctx,files,'/',false)
        ctx.body = result
    }

    @request('GET', '/files/versions/{id}/{version}')
    @summary('get file content by file id and version id')
    @description('查询指定文件版本内容')
    @path({ id: { type: 'string', required: true },
        version: { type: 'string', required: true } })
    static async getVersionFileContent(ctx) {
        let result = await getFileVersionContent(ctx.client,ctx.user,ctx.params.id,ctx.params.version)
        ctx.body = result
    }
}
